package model.app;

import javax.xml.bind.annotation.*;
import java.util.ArrayList;
import java.util.List;

/**
 * Created with IntelliJ IDEA.
 * Author: Kostika Gorica
 * User:   kosta
 * Date:   3/9/13
 * Time:   8:41 PM
 */
@XmlAccessorType(XmlAccessType.FIELD)
@XmlAccessorOrder(XmlAccessOrder.ALPHABETICAL)
@XmlRootElement(name = "department")
public class Department {
    private int id;
    @XmlElement(nillable = true)
    private String emertimi;
    @XmlElement(nillable = true)
    private String adresa;
    @XmlElement(nillable = true)
    private String funksioni;
    private int enabled;
    private int parentID;
    @XmlAnyElement(lax = true)
    @XmlElementRef(type = Department.class)
    @XmlElementWrapper
    private List<Department> childDepartments;

    public Department(){
        this(0,"","","",1,0);
    }

    public Department(int id, String emertimi, String adresa, String funksioni, int enabled, int parentID) {
        this.id = id;
        this.emertimi = emertimi;
        this.adresa = adresa;
        this.funksioni = funksioni;
        this.enabled = enabled;
        this.parentID = parentID;
        this.childDepartments=new ArrayList<Department>();
    }


    public int getId() {
        return id;
    }

    public void setId(int id) {
        this.id = id;
    }

    public String getEmertimi() {
        return emertimi;
    }

    public void setEmertimi(String emertimi) {
        this.emertimi = emertimi;
    }

    public String getAdresa() {
        return adresa;
    }

    public void setAdresa(String adresa) {
        this.adresa = adresa;
    }

    public String getFunksioni() {
        return funksioni;
    }

    public void setFunksioni(String funksioni) {
        this.funksioni = funksioni;
    }

    public int getEnabled() {
        return enabled;
    }

    public void setEnabled(int enabled) {
        this.enabled = enabled;
    }

    public int getParentID() {
        return parentID;
    }

    public void setParentID(int parentID) {
        this.parentID = parentID;
    }

    public List<Department> getChildDepartments() {
        return childDepartments;
    }

    public void setChildDepartments(List<Department> childDepartments) {
        this.childDepartments = childDepartments;
    }

    public void addChildDepartment(Department department){
        this.childDepartments.add(department);
    }

}
